﻿#region 程序集 VanillaPsycastsExpanded, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null
// C:\code\MyMod\MOD\bin\this!!!!!!!1\1.4\Assemblies\VanillaPsycastsExpanded.dll
// Decompiled with ICSharpCode.Decompiler 7.1.0.6543
#endregion

using System.Collections.Generic;
using System.Security.Cryptography;
using Core;
using RI_Talisman;
using RimWorld;
using UnityEngine;
using Verse;
using static UnityEngine.GraphicsBuffer;

namespace WhoXiuXian
{
    public class RI_IncidentWorker_IncentiveTalisman : IncidentWorker
    {
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            Map map = (Map)parms.target;
            foreach (Pawn pawn in map.mapPawns.PawnsInFaction(Faction.OfPlayer))
            {
                if (EnergyRootUtility.IsHaveRoot(pawn))
                {
                    if (EnergyRootUtility.GetRoot(pawn).route == RI_T_DefOfs.TalismanCreating)
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;
            foreach (Pawn pawn in map.mapPawns.PawnsInFaction(Faction.OfPlayer))
            {
                if (EnergyRootUtility.IsHaveRoot(pawn))
                {
                    if (EnergyRootUtility.GetRoot(pawn).route == RI_T_DefOfs.TalismanCreating)
                    {
                        InspirationDef randomAvailableInspirationDef = pawn.mindState.inspirationHandler.GetRandomAvailableInspirationDef();
                        if (randomAvailableInspirationDef != null)
                        {
                            pawn.mindState.inspirationHandler.TryStartInspiration(InspirationDefOf.Inspired_Creativity);
                        }
                    }
                }
            }
            return false;
        }
    }
}
